/*
 * Application\Src\Library\pressure_sensor\pressure_sensor.c
 *
 * P1 Pressure Sensor function
 *
 * Author: Chao-Chi Kuo <chaochi_kuo@systech.com.tw>
 * Copyright (c) 2010 SYSTEMS & TECHNOLOGY CORP. <http://www.systech.com.tw/>
 * All rights reserved.
 *
 * Modifications:
 * 2010/04/20 Chao-Chi Kuo	first implemetation
 *
 * $Id: pressure_sensor.c 164 2010-07-15 10:01:44Z chaochi_kuo $
 */
#include "config.h"
#include "pressure_sensor.h"
#include "MS5801.h"
#include "stm32f10x.h"

typedef struct _PSEN_FUN {
	int (*init)(void);
	long (*get_temperature)(void);
	long (*get_pressure)(void);
	long (*get_altitude)(void);
}PSEN_FUN;

PSEN_FUN psen;

int PSensor_Init(void)
{
/*
#if (USE_BMP085)
	psen.init				= BMP085_Init;
	psen.get_temperature	= BMP085_Get_Temperature;
	psen.get_pressure		= BMP085_Get_Pressure;
	psen.get_altitude		= BMP085_Get_Altitude;
#endif
*/

	return (*psen.init)();
}

/*void PSensor_ioctl(int ioctl, char *arg)
{
	float *ret;
	
	ret = (float *)arg;
	switch (ioctl)
	{
	case PS_GET_TEMPERATURE:
		*ret = (*psen.get_temperature)();
		break;
	case PS_GET_PRESSURE:
		*ret = (*psen.get_pressure)();
		break;
	case PS_GET_ALTITUDE:
		*ret = (*psen.get_altitude)();
		break;
	default:
		break;
	}
}*/
//fenris 20101207 test pressure
void PSensor_ioctl(int ioctl, char *arg)
{
	char *ret;
	
	ret = arg;
	switch (ioctl)
	{
	case PS_GET_TEMPERATURE:
		*ret = (*psen.get_temperature)();
		break;
	case PS_GET_PRESSURE:
		*ret = (*psen.get_pressure)();
		break;
	case PS_GET_ALTITUDE:
		*ret = (*psen.get_altitude)();
		break;
	default:
		break;
	}
}



